tools/xenstore: correctly handle errors from read_message
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Wed, 1 Sep 2010 13:37:18 +0000 (14:37 +0100)
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>
Wed, 1 Sep 2010 13:37:18 +0000 (14:37 +0100)
commit0de6578197537de37c8e0250f0f7b6537d103052
tree1b030f0cd5fd88f108e6a36f1b80a4b72de9a5aa
parent09cae24637fb571d6216a7bd45e486a6c3d4d8e3
tools/xenstore: correctly handle errors from read_message

The return value of read_message needs to be checked in order to avoid
waiting forever for a message if there is an error on the communication
channel with xenstore. Currently, this is only checked if USE_PTHREAD is
defined (by checking for read thread exit), and that path is prone to
deadlock if request_mutex is held while waiting.

Since the failure of read_message leaves the socket in an undefined
state, close the socket and force all threads waiting on a read to return.

This also fixes xs_read_watch in the case where a read thread is not
running (in particular, this will happen if !USE_PTHREAD) by having it
read from the communication channel in the same way as read_reply.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xenstore/xs.c